package com.lanchuan.soft.controller;

import com.lanchuan.soft.entity.ParamEvent;
import com.lanchuan.soft.service.IEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("event")
public class EventController {

    private IEventService eventService;

    @Autowired
    public EventController(IEventService eventService) {
        this.eventService = eventService;
    }

    // 根据条件分页查询事件列表
    @RequestMapping("findEventListByCondition")
    public Map<String, Object> findEventListByCondition(@RequestBody ParamEvent paramEvent) {
        return eventService.findEventListByCondition(paramEvent);
    }

    // 根据条件分页查询事件列表
    @RequestMapping("findEventListByCondition2")
    public Map<String, Object> findEventListByCondition2(ParamEvent paramEvent) {
        return eventService.findEventListByCondition(paramEvent);
    }

    // 生成事件
    @RequestMapping("createEvent")
    public Map<String, Object> createEvent(ParamEvent paramEvent) {
        return eventService.createEvent(paramEvent);
    }

    // 更新事件分类
    @RequestMapping("updateEventType")
    public Map<String, Object> updateEventType(@RequestBody ParamEvent paramEvent) {
        return eventService.updateEventType(paramEvent);
    }

    // 事件上报至决策机构
    @RequestMapping("reportToLeader")
    public Map<String, Object> reportToLeader(@RequestBody ParamEvent paramEvent) {
        return eventService.reportToLeader(paramEvent);
    }

    // 决策机构下达事件指示
    @RequestMapping("commandToPlatform")
    public Map<String, Object> commandToPlatform(ParamEvent paramEvent) {
        return eventService.commandToPlatform(paramEvent);
    }

    // 平台下达指令到队员
    @RequestMapping("commandToWorker")
    public Map<String, Object> commandToWorker(@RequestBody ParamEvent paramEvent) {
        return eventService.commandToWorker(paramEvent);
    }

    // 平台下达指令到队员
    @RequestMapping("commandToWorker2")
    public Map<String, Object> commandToWorker2(ParamEvent paramEvent) {
        return eventService.commandToWorker(paramEvent);
    }

    // 事件转交至有关部门
    @RequestMapping("reportToDepartment")
    public Map<String, Object> reportToDepartment(@RequestBody ParamEvent paramEvent) {
        return eventService.reportToDepartment(paramEvent);
    }

    // 队员解决事件
    @RequestMapping("solveByWorker")
    public Map<String, Object> solveByWorker(ParamEvent paramEvent) {
        return eventService.solveByWorker(paramEvent);
    }

    // 有关部门解决事件
    @RequestMapping("solveByDepartment")
    public Map<String, Object> solveByDepartment(@RequestBody ParamEvent paramEvent) {
        return eventService.solveByDepartment(paramEvent);
    }

    // 上传图片
    @RequestMapping("fileUpload")
    public Map<String, Object> fileUpload(@RequestParam("file") MultipartFile file) {
        return eventService.uploadImage(file);
    }

    // 上传已经解决问题
    @RequestMapping("createResolveEvent")
    public Map<String, Object> createResolveEvent(ParamEvent paramEvent) {
        return eventService.createResolveEvent(paramEvent);
    }

    // 删除问题
    @RequestMapping("deleteEvent")
    public Map<String, Object> deleteEvent(@RequestBody ParamEvent paramEvent) {
        return eventService.deleteEvent(paramEvent);
    }
}
